/*
 * GAME.c
 *
 * Created: 05.11.2012 10:00:59
 *  Author: mariuvi
 */ 
#define F_CPU 8500000

#include "definitions.h"
#include <avr/io.h>


#define SOLENOID PD6


void SOLENOID_init()
{
	BIT_SET(DDRD, SOLENOID);
	BIT_SET(PORTD, SOLENOID);
	
	//Init timer2 with 1/1024 prescaler
	BIT_SET(TCCR2,CS22);
	BIT_SET(TCCR2,CS20);	
}

void SOLENOID_shoot()
{
	BIT_CLEAR(PORTD, SOLENOID);
	TCNT2 = 0;
	int i =0;
	//Wait 200 ms
	while(i < 20)
	{
		if(TCNT2 > 100)
		{
			i++;
			TCNT2 = 0;
		}	
	}
	BIT_SET(PORTD, SOLENOID);
}
